<template>
  <div>
    <el-dialog
      :visible="detailsVisible"
      title="工单详情"
      width="640px"
      style="font-size: 16px;
        font-weight: 600;
        color: #333;"
      class="detail"
      @close="closeFn"
    >
      <div class="detailsBody">
        <div v-if="taskDetail.taskStatus===3" class="detailsState">
          <img src="../../../assets/png1.png" alt="">
          <span>取消</span>
          <img src="http://likede2-admin.itheima.net/img/pic_3.e8208e34.png" alt="">
        </div>
        <div v-if="taskDetail.taskStatus===1" class="detailsState">
          <img src="../../../assets/png2.png" alt="">
          <span>待办</span>
          <img src="http://likede2-admin.itheima.net/img/pic_1.834b274c.png" alt="">
        </div>
        <div v-if="taskDetail.taskStatus===4" class="detailsState">
          <img src="../../../assets/png3.png" alt="">
          <span>完成</span>
          <img src="http://likede2-admin.itheima.net/img/pic_4.3b5af41c.png" alt="">
        </div>
        <div class="detailsInfo">

          <span>设备编号：{{ taskDetail.innerCode }}</span>
          <span>创建日期：{{ taskDetail.createTime }}</span>
          <span v-if="taskDetail.taskStatus===3">取消日期：{{ taskDetail.updateTime }}</span>
          <span v-if="taskDetail.taskStatus===4">完成日期：{{ taskDetail.updateTime }}</span>
          <span>运营人员：{{ taskDetail.userName }}</span>
          <span>工单类型：补货工单</span>
          <span>补货数量：补货详情</span>
          <span>工单方式：{{ taskDetail.createType === 1 ? "手动" : '自动' }}</span>
          <span v-if="taskDetail.taskStatus===3">取消原因：</span>
          <span v-if="taskDetail.taskStatus===4 || taskDetail.taskStatus=== 1">备注：{{ taskDetail.desc }}</span>
        </div>
      </div>
      <el-row v-if="taskDetail.taskStatus===3" type="flex" justify="center">
        <el-button @click="toggleFn">重新创建</el-button>
      </el-row>
      <el-row v-if="taskDetail.taskStatus===1" type="flex" justify="center">
        <el-button @click="centerDialogVisible = true">取消工单</el-button>
      </el-row>
    </el-dialog>
    <div class="cancel">
      <el-dialog
        :visible.sync="centerDialogVisible"
        width="30%"
        center
      >
        <span>
          <i class="el-icon-warning" />
          取消工单后，将不能恢复，是否确认取消？</span>
        <span slot="footer" class="dialog-footer">
          <el-button size="mini" @click="centerDialogVisible = false">取 消</el-button>
          <el-button size="mini" type="primary" @click="centerDialogVisible = false">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    detailsVisible: {
      type: Boolean,
      required: true
    },
    taskDetail: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      centerDialogVisible: false
    }
  },
  methods: {
    toggleFn() {
      this.closeFn()
      this.$emit('showAdd')
    },
    closeFn() {
      this.$emit('update:detailsVisible', false)
    }
  }
}
</script>

<style lang="scss" scoped>
.detail{
  .detailsBody{
  margin-bottom: 40px;
  .detailsState{
      display: flex;
      align-items: center;
      height: 54px;
      margin-bottom: 25px;
      margin-top: -10px;
      background-color: hsla(0,0%,92.5%,.39);
        img:nth-child(1){
          margin-left: 22px;
        }
        span{
          flex: 1;
          margin-left: 16px;
          color: rgba(0,0,0,.85);
          font-weight: normal;
        }
        img:nth-child(3){
            margin-right: 76px;
            margin-bottom: 7px;
        }
  }
  .detailsInfo{
    display: flex;
    margin-left: 45px;
    color: #606266;
    font-weight: normal;
    width: 630px;
    flex-wrap: wrap;
      span{
        display: flex;
        width: 315px;
        margin-bottom: 20px;
      }
  }
}
.el-button{
  width: 80px!important;
  height: 36px;
  padding: 0;
  background-color: #fbf4f0!important;
  border: none;
  color: #655b56!important;
}
}
.cancel{
  margin-left: 30px;
  span:nth-child(1){
    font-size: 16px;
    color: #000;
    font-weight: 500;
    line-height: 24px;
    .el-icon-warning{
      padding-top: 2px;
    padding-right: 17px;
    font-size: 20px!important;
    color: #ff665f;
    }
  }
}

</style>
